//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package weaver.interfaces.expense.action.zcpz;

import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.expense.ExpenseImp;
import weaver.interfaces.expense.OAExpenseBean;
import weaver.interfaces.util.ExpenseInfoUtil;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

public class ZCPZ_Voucher extends BaseBean implements Action {
    public ZCPZ_Voucher() {
    }

    public String execute(RequestInfo requestInfo) {
        try {
            String workflowid = requestInfo.getWorkflowid();
            String requestid = requestInfo.getRequestid();
            this.writeLog("进入ZCPZ_Voucher-----------" + requestid);
            RecordSet rs = new RecordSet();
            rs.executeSql("select formid from workflow_base where id = " + workflowid);
            rs.next();
            String formid = rs.getString("formid");
            String formtable = "formtable_main_" + formid.replaceAll("-", "");
            String ccode = "";
            double amount = 0.0D;
            String cexpenseitemcode = "";
            String citemcode = "";
            String ly = "";
            String iyear = "";
//            rs.execute("select id,ks,zcxm,xm,pjje,ly,sqrq,kth1,xglc,zf from " + formtable + " where requestid=" + requestid);
            rs.execute("select id,ks,zcxm,xm,pjje,ly,sqrq,kthxin,zf,huansuan from " + formtable + " where requestid=" + requestid);
            rs.next();
            ExpenseInfoUtil expenseInfoUtil = new ExpenseInfoUtil();
            ccode = expenseInfoUtil.getKsbm(Util.null2String(rs.getString("ks")));
            String cname = expenseInfoUtil.getCname(ccode);
            amount = Util.getDoubleValue(rs.getString("pjje").replace(",", ""), 0.0D);

            amount = Util.getDoubleValue(rs.getString("huansuan").replace(",", ""), 0.0D);

            citemcode = Util.null2String(rs.getString("xm"));
            String citemname = expenseInfoUtil.getCtn(citemcode);
            cexpenseitemcode = Util.null2String(rs.getString("zcxm"));
            String zf = Util.null2String(rs.getString("zf"));
            String cexpenseitemname = expenseInfoUtil.getCItemName(cexpenseitemcode);
            String kth = Util.null2String(rs.getString("kthxin"));
            ly = Util.null2String(rs.getString("ly"));
            iyear = Util.null2String(rs.getString("sqrq"));
            //支付方式
            String paymentMethod = Util.null2String(rs.getString("zf"));
            //开户行
            String openingBank = Util.null2String(rs.getString("khh"));
            //帐号
            String accounts = Util.null2String(rs.getString("zh"));


            OAExpenseBean oaExpenseBean = new OAExpenseBean();
            oaExpenseBean.setAmount(String.valueOf(amount));
            oaExpenseBean.setBilldate(iyear);
            oaExpenseBean.setBilltype("2");
            oaExpenseBean.setCcode(ccode);
            oaExpenseBean.setCname(cname);
            oaExpenseBean.setCexpenseitemcode(cexpenseitemcode);
            oaExpenseBean.setCexpenseitemname(cexpenseitemname);
            oaExpenseBean.setCitemcode(citemcode);
            oaExpenseBean.setCitemname(citemname);
            oaExpenseBean.setLy(ly);
            oaExpenseBean.setZffs(zf);
            oaExpenseBean.setRequestid(requestid);

            oaExpenseBean.setPaymentmethod(paymentMethod);
            oaExpenseBean.setOpeningbank(openingBank);
            oaExpenseBean.setAccounts(accounts);

            ExpenseImp expenseImp = new ExpenseImp();
            if(!expenseImp.insetExpense(oaExpenseBean)) {
                requestInfo.getRequestManager().setMessageid("1111111111");
                requestInfo.getRequestManager().setMessagecontent("凭证保存失败");
                return "1";
            } else {
                return "1";
            }
        } catch (Exception var22) {
            requestInfo.getRequestManager().setMessageid("1111111111");
            requestInfo.getRequestManager().setMessagecontent(var22.getMessage());
            return "1";
        }
    }
}
